//
//  YCApplyPayCell.m
//  YCSchool
//
//  Created by gmall on 16/5/5.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  报名费支付table cell

#import "YCApplyPayCell.h"

@interface YCApplyPayCell ()

/** 选中图标  */
@property (nonatomic, weak) UIImageView *iconView;
/** 支付方式  */
@property (nonatomic, weak) UILabel *payMethodLabel;
/** 金额  */
@property (nonatomic, weak) UILabel *costLabel;

@end

@implementation YCApplyPayCell

+ (instancetype)tableViewCellWithTableView:(UITableView *)tableView withIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"applyPayCell";
    YCApplyPayCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[YCApplyPayCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self makeSubview];
    }
    return self;
}

- (void)makeSubview
{
    UIImageView *iconImageView = [[UIImageView alloc] init];
    iconImageView.image = [UIImage imageNamed:@"ms_normal"];
    iconImageView.highlightedImage = [UIImage imageNamed:@"ms_select"];
    [self.contentView addSubview:iconImageView];
    self.iconView = iconImageView;
    
    UILabel *payMethodLabel = [[UILabel alloc] init];
    payMethodLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:payMethodLabel];
    self.payMethodLabel = payMethodLabel;

    UILabel *costLabel = [[UILabel alloc] init];
    costLabel.textColor = [UIColor redColor];
    [self.contentView addSubview:costLabel];
    self.costLabel = costLabel;
    
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(25);
        make.centerY.equalTo(self.contentView);
        make.height.with.equalTo(@22);
    }];
    
    [costLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-15);
        make.centerY.equalTo(self.contentView);
    }];
    
    [payMethodLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(costLabel.mas_left).offset(-10);
        make.centerY.equalTo(self.contentView);
    }];
}

- (void)setModel:(YCApplyCostPayModel *)model
{
    _model = model;
    self.iconView.highlighted = model.select;
    self.payMethodLabel.text = model.payMethod;
    self.costLabel.text = [NSString stringWithFormat:@"¥ %zd",model.costValue];

}

@end
